<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>发布产品</title>
    <script type="text/javascript">
        $(function () {
            $("#parent_id").change(function () {
                $(this).val();
            });
            $("form").submit(function(){
               var minInvestAmount = $("#minInvestAmount").val();
                if(minInvestAmount==""){
                    alert("请输入最低投资额");
                    return false;
                }else if($.isNumeric(minInvestAmount)==false){
                    alert("最低投资额必须是数字");
                    return false;
                }
                else if(minInvestAmount<100){
                    alert("最低投资额至少要100万");
                    return false;
                }
                return true;
            });

        })
    </script>
</head>
<body>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title">
            基金管理
            <small>发布基金</small>
        </h3>
        <ul class="page-breadcrumb breadcrumb">
            <li><i class="fa fa-home"></i> <a href="${ctx}"> 首页 </a> <i
                    class="fa fa-angle-right"></i></li>
            <li><a href="${ctx}/product"> 基金管理 </a> <i
                    class="fa fa-angle-right"></i></li>
            <li><a href="#"> 发布基金 </a></li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
    </div>
</div>
<!-- END PAGE HEADER-->
<!------内容区---->
<div class="main">

    <div class="row">
        <div class="col-md-12">
            <form:form modelAttribute="ProductAddModel" method="post"
                       class="form-horizontal">
                <div class="form-group">
                    <label class="control-label col-md-3">基金名称：</label>

                    <div class="col-md-4">
                        <form:input path="productName" cssClass="form-control" placeholder=""></form:input>
                    </div>
                    <form:errors path="productName" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">基金编号：</label>

                    <div class="col-md-4">
                        <form:input path="productCode" cssClass="form-control" placeholder=""></form:input>
                    </div>
                    <form:errors path="productCode" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">基金图片：</label>

                    <div class="col-md-4">
                        <div class="input-group">
                            <img alt="" id="aimg" src="${ctx}/assets/img/upload_img.png" width="100px" height="100px"/>
                            <form:hidden path="productPic" id="product_pic"/>
                            <input id="image3" type="button" value="上传图片" style="display: none"/>
                        </div>

                        <form:errors path="productPic" cssClass="field-validation-error" element="div"></form:errors>
                    </div>

                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">基金分类：</label>

                    <div class="col-md-4">
                        <form:input path="productClassName" cssClass="form-control"></form:input>
                            <%--<form:select path="productClassId" class="form-control js-roleSelect">
                                <form:option value="">--基金分类--</form:option>
                                <form:options items="${ProductAddModel.classList}" itemValue="classId" itemLabel="className" />
                            </form:select>--%>
                    </div>
                    <form:errors path="productClassName" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">基金管理人：</label>

                    <div class="col-md-4">
                        <form:select path="fundCompanyId" class="form-control js-roleSelect">
                            <form:option value="">--请选择基金管理人--</form:option>
                            <form:options items="${ProductAddModel.companyList}" itemValue="companyId"
                                          itemLabel="companyName"/>
                        </form:select>
                    </div>
                    <form:errors path="fundCompanyId" cssClass="field-validation-error" element="div"></form:errors>
                </div>

                <%--<div class="form-group">
                    <label class="control-label col-md-3">交易经纪（券商）：</label>

                    <div class="col-md-4">
                        <form:input path="fundTradingBroker" cssClass="form-control" placeholder=""></form:input>
                    </div>
                    <form:errors path="fundTradingBroker" cssClass="field-validation-error" element="div"></form:errors>
                </div>--%>
                <div class="form-group">
                    <label class="control-label col-md-3">基金经理：</label>

                    <div class="col-md-4">
                        <form:select path="fundManagerId" class="form-control js-roleSelect">
                            <form:option value="">--请选择基金经理--</form:option>
                            <form:options items="${ProductAddModel.managerList}" itemValue="managerId"
                                          itemLabel="managerName"/>
                        </form:select>
                    </div>
                    <form:errors path="fundManagerId" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">托管人名称：</label>

                    <div class="col-md-4">
                        <form:input path="fundCustodianName" cssClass="form-control" placeholder=""></form:input>
                    </div>
                    <form:errors path="fundCustodianName" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <%--<div class="form-group">
                    <label class="control-label col-md-3">基金类型：</label>

                    <div class="col-md-4">
                        <form:input path="fundTypeName" cssClass="form-control" placeholder=""></form:input>
                    </div>
                    <form:errors path="fundTypeName" cssClass="field-validation-error" element="div"></form:errors>
                </div>--%>
                <%--<div class="form-group">
                    <label class="control-label col-md-3">披露标识：</label>

                    <div class="col-md-4">
                        <div class="radio-list">
                            <select name="fundGrade" class="form-control js-roleSelect">
                                <option value="AAA">AAA</option>
                                <option value="AA">AA</option>
                                <option value="A">A</option>
                                <option value="B+">B+</option>
                                <option value="B-">B-</option>
                                <option value="C+">C+</option>
                                <option value="C-">C-</option>
                            </select>

                        </div>
                    </div>
                </div>--%>
                <div class="form-group">
                    <label class="control-label col-md-3">基金总规模：</label>

                    <div class="col-md-3">
                        <div class="input-group">
                            <form:input path="productTotalScale" cssClass="form-control" maxlength="10"
                                        placeholder=""></form:input>
                            <span class="input-group-addon">万元</span>
                        </div>
                    </div>
                    <form:errors path="productTotalScale" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">初始规模：</label>

                    <div class="col-md-3">
                        <div class="input-group">
                            <form:input path="productInitialScale" cssClass="form-control" maxlength="10"
                                        placeholder=""></form:input>
                            <span class="input-group-addon">万元</span>
                        </div>
                    </div>
                    <form:errors path="productInitialScale" cssClass="field-validation-error"
                                 element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">存续期限：</label>

                    <div class="col-md-3">
                        <div class="input-group">
                            <form:input path="productCycle" cssClass="form-control" maxlength="10"
                                        placeholder=""></form:input>

                        </div>
                    </div>
                    <form:errors path="productCycle" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">投资期限：</label>

                    <div class="col-md-2">
                        <div class="input-group">
                            <form:input path="productDeadline" cssClass="form-control" maxlength="2"
                                        placeholder=""></form:input>
                            <span class="input-group-addon">月</span>
                        </div>
                        <form:errors path="productDeadline" cssClass="field-validation-error"
                                     element="div"></form:errors>

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">成立时间：</label>

                    <div class="col-md-2">
                        <div class="input-daterange input-group">
                            <form:input path="registerDate" cssClass="form-control" maxlength="10"
                                        placeholder=""></form:input>
                        </div>

                        <form:errors path="registerDate" cssClass="field-validation-error" element="div"></form:errors>
                    </div>

                </div>

                <div class="form-group">
                    <label class="control-label col-md-3">投资者收益分成比例：</label>

                    <div class="col-md-2">
                        <div class="input-group">
                            <form:input path="investorDivided" cssClass="form-control" maxlength="2"
                                        placeholder=""></form:input>
                            <span class="input-group-addon">%</span>
                        </div>
                        <form:errors path="investorDivided" cssClass="field-validation-error"
                                     element="div"></form:errors>
                    </div>
                </div>
                <%--<div class="form-group">
                    <label class="control-label col-md-3">投资顾问收益分成比例：</label>

                    <div class="col-md-2">
                        <div class="input-group">
                            <form:input path="adviserDivided" cssClass="form-control" maxlength="2"
                                        placeholder=""></form:input>
                            <span class="input-group-addon">%</span>
                        </div>
                        <form:errors path="adviserDivided" cssClass="field-validation-error"
                                     element="div"></form:errors>
                    </div>
                </div>--%>
                <div class="form-group">
                    <label class="control-label col-md-3">管理人收益分成比例：</label>

                    <div class="col-md-2">
                        <div class="input-group">
                            <form:input path="platformDivided" cssClass="form-control" maxlength="2"
                                        placeholder=""></form:input>

                            <span class="input-group-addon">%</span>
                        </div>
                        <form:errors path="platformDivided" cssClass="field-validation-error"
                                     element="div"></form:errors>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">投资类型：</label>

                    <div class="col-md-4">
                        <div class="radio-list">
                            <form:input path="investmentType" cssClass="form-control" placeholder=""></form:input>
                            <%--<select name="investmentType" class="form-control js-roleSelect">
                                <option value="1">股票</option>
                                <option value="2">基金</option>
                                <option value="3">债权</option>
                            </select>--%>

                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">投资策略：</label>

                    <div class="col-md-4">
                        <form:textarea path="investmentStrategy" cssClass="form-control" cssStyle="width: 100%;"
                                       cols="10" rows="3"></form:textarea>

                    </div>
                    <form:errors path="investmentStrategy" cssClass="field-validation-error"
                                 element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">子策略：</label>

                    <div class="col-md-4">
                        <form:input path="investmentChildStrategy" cssClass="form-control"></form:input>
                    </div>
                    <form:errors path="investmentChildStrategy" cssClass="field-validation-error"
                                 element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">封闭期(月)：</label>

                    <div class="col-md-2">
                        <div class="input-group">
                            <form:input path="fundClosedPeriod" cssClass="form-control" maxlength="2"
                                        placeholder=""></form:input>
                            <span class="input-group-addon">月</span>
                        </div>
                        <form:errors path="fundClosedPeriod" cssClass="field-validation-error"
                                     element="div"></form:errors>

                    </div>
                </div>
                <%--<div class="form-group">
                    <label class="control-label col-md-3">开放日：</label>

                    <div class="col-md-4">
                        <form:input path="fundOpenDay" cssClass="form-control"></form:input>
                    </div>
                    <form:errors path="fundOpenDay" cssClass="field-validation-error" element="div"></form:errors>
                </div>--%>
                <div class="form-group">
                    <label class="control-label col-md-3">最低投资金额：</label>

                    <div class="col-md-3">
                        <div class="input-group">
                            <form:input path="minInvestAmount" cssClass="form-control" maxlength="3"
                                        placeholder=""></form:input>
                            <span class="input-group-addon">万元</span>
                        </div>
                    </div>
                    <form:errors path="minInvestAmount" cssClass="field-validation-error" element="div"></form:errors>
                </div>


                <div class="form-group">
                    <label class="control-label col-md-3">基金详情：</label>

                    <div class="col-md-8">
                        <form:textarea path="productDetail" cssClass="form-control"
                                       cssStyle="width: 100%; height: 400px;" cols="10" rows="3"></form:textarea>
                    </div>
                    <form:errors path="productDetail" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">状态：</label>

                    <div class="col-md-4">
                        <form:select path="status" class="form-control js-roleSelect">
                            <form:options items="${statusList}" itemValue="id" itemLabel="name"/>
                        </form:select>

                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-9 col-md-offset-3">
                        <button type="submit" class="btn blue">发布</button>
                        <span class="field-validation-error">${error}</span>
                    </div>
                </div>
            </form:form>
        </div>
    </div>

</div>
<myfooter>
    <style>
        .ke-upload-area input .ke-upload-file {
            background: url("/assets/img/upload_img.png");
            background-size: 100% 100%;
            height: 80px;
            width: 100px;
            display: block;
            border: none;;;
            top: 0px;
        }
    </style>
    <script>
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="productDetail"]', {
                allowFileManager: true,
                uploadJson: '${ctx}/file_upload?dir=image'
            });


            K('#aimg').click(function () {
                editor.loadPlugin('image', function () {
                    editor.plugin.imageDialog({
                        showRemote: false,
                        imageUrl: K('#product_pic').val(),
                        clickFn: function (url, title, width, height, border, align) {
                            K('#product_pic').val(url);
                            K('#aimg').attr("src", url);
                            editor.hideDialog();
                        }
                    });
                });
            });


            /*var uploadbutton = K.uploadbutton({
             button : K('#image3')[0],
             fieldName : 'imgFile',
             url : '
            ${ctx}/file_upload?dir=image',
             afterUpload : function(data) {
             if (data.error === 0) {
             var url = K.formatUrl(data.url, 'absolute');

             K('#aimg').attr("src", url);
             K('#product_pic').val(url);
             } else {
             alert(data.message);
             }
             },
             afterError : function(str) {
             alert('自定义错误信息: ' + str);
             }
             });
             uploadbutton.fileBox.change(function(e) {
             uploadbutton.submit();
             });*/
        });
    </script>
</myfooter>
</body>
</html>